//
//
#include <cstdio>
#include <cmath>

int n, i , j, sum;
unsigned int x;
int main(){
	freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	int t;
	scanf("%d", &t);
	while(t--){

	scanf("%d", &n);
	j=(int)sqrt(n)+1;
	sum=0;
	for(i=0;i<=j;){
		x=(i*i)+(j*j);
		if(x<n)++i;
		else if(x>n)--j;
		else{
			sum++;
			++i;
			--j;
		}
	}
	printf("%d\n", sum);
	
	}
	return 0;
}
